<?php
	if (!isset($_GET['id'])) exit;
	
	require_once('../classes/Config.class.php');
	require_once('../classes/Database.class.php');
	
	$Config = new Config();
	$DB = new Database();
	
	$id = $_GET['id'];
	
	if (!get_magic_quotes_gpc()) {
		$id = addslashes($id);
	}
	
	$sql = $DB -> select('*', 'Events_Ftse_Range', "EventID = $id");
	$row = $DB -> row($sql);
	$from = $row['TimeFrom'];
	$to = $row['TimeTo'];
	
	$sql = $DB -> select(
		'*',
		'Storage_Ftse',
		"Timestamp >= $from AND Timestamp <= $to",
		false,
		'Timestamp',
		'ASC'
	);
	
	while ($row = $DB -> row($sql)) {
		echo "a,$row[Timestamp],$row[Ask]\nb,$row[Timestamp],$row[Bid]\n";
	}
	
	$sql = $DB -> query("
		SELECT *
		FROM `Events_News`, `Storage_News`
		WHERE `Events_News`.`EventID` = $id
		AND `Events_News`.`NewsID` = `Storage_News`.`ID`
	");
	
	while ($row = $DB -> row($sql)) {
		echo "n,$row[Timestamp],$row[Score]\n";
	}
?>